<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>等级分数设置</title>
		<link rel="stylesheet" type="text/css" href="../static/common.css" />
		<link rel="stylesheet" type="text/css" href="static/css/asscom.css" />
		<link rel="stylesheet" type="text/css" href="static/css/index.css" />

	</head>
	<body>

		<!-- right -->
		<div class="rightBox">

			
			<div class="nav1 clearfix">
				<a href="gradeconfig.html" class="active btnAct1">等级分数</a>
				<a href="valueconfig.html" class="btnAct1">产值系数</a>
				<a href="scaleconfig.html" class="btnAct1">规模分数</a>
				<a href="numberconfig.html" class="btnAct1">参评个数</a>
				<a href="specialconfig.html" class="btnAct1">特殊项目</a>
				<a href="difficultconfig.html" class="btnAct1">施工难度</a>
				<a href="typeconfig.html" class="btnAct1">队伍类型</a>

			</div>
			<div class="config clearfix">
				<!-- 评分等级 -->
				<div class="conTable" id="grade">
					<h3>等级分数设置 <span class="helpFont" id="helpFont" title="点击查看说明及帮助"></span></h3>
					<span class="err"></span>
					<div id="helpContext" class="helpContext">
						<p>产值系数只能为非负数，并且精确小数后8位 注！(正常产值，近三年系数，之前年份系数为系统工作必有的参数，请勿随意操作)</p>
					</div>
					<table>
						<thead>
							<tr>
								<th>级别</th>
								<th>分数</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>

						</tbody>
					</table>
				</div>

			</div>
		</div>
	</body>
</html>
<script src="../static/js/jquery-1.8.3.js" type="text/javascript" charset="utf-8"></script>
<script src="../static/dx.js" type="text/javascript" charset="utf-8"></script>
<!-- <script src="static/js/common.js" type="text/javascript" charset="utf-8"></script> -->
<script type="text/javascript">
	$(document).ready(function() {
		domAjax();


	})
	//默认加载
	function domAjax() {
		DX.ajax_method({
			'type': 'POST',
			'url': '/eva/ads/findAllAddScore',
			'param': {},
			'callBack': tableCall
		})
	}
	// 渲染回调
	function tableCall(res) {

		console.log(res);
		if (res.code != '200') {
			console.log('没有数据');
			return;
		}

		var grade = ''; //评分等级
		if (res.data[1].length != 0 && res.data[1] != null) {
			// grade = each(res.data[1]);
			$.each(res.data[1], function(i, val) {
				grade += '<tr status="' + val.status + '">';
				grade += "<td class='clum1'>" + val.add_item + "</td>";
				grade += "<td class='clum2'><input value=" + val.project_score + " class='tableEdit' /></td>";
				grade += "<td id='" + val.aid + "'><span class='mod1'>修改</span></td>";
				grade += '</tr>';
			})
		}
		$('#grade table tbody').html(grade);
		// $('#grade tbody tr').click(function(){
		// 	DX.clickTr($(this),['input']);			
		// })
		//点击变色
		// $('#grade table tbody tr').click(function() {
		// 	DX.clickTr($(this), ['input']);
		// })

		//修改
		$('.mod1').click(function() {
			mod($(this), '/eva/ads/updateAddScore');
		})

	}
	/* 修改
	 * obj 当前元素$(this)
	 * url 接口地址
	 */
	function mod(obj, url) {
		$('.err').hide();
		var id = obj.parent().attr('id');
		var name = obj.parent().siblings('.clum1').text();
		var value = obj.parent().siblings('.clum2').find('input').val();
		var status = obj.parents('tr').attr('status');
		var res = {
			'aid': id,
			'add_item': name,
			'project_score': value
		};


		var isvalueN = DX.isNull(value);
		if (isvalueN) {

			obj.parents('.conTable').find('.err').show();
			obj.parents('.conTable').find('.err').html('分数不能为空');
			return;
		}
		var isvalue = DX.isInt(value);
		if (!isvalue) {
			obj.parent().siblings('.clum2').find('input').val('');
			obj.parents('.conTable').find('.err').show();
			obj.parents('.conTable').find('.err').html('分数只能为正整数');
			return;
		}


		DX.ajax_method({
			'type': 'POST',
			'url': url,
			'param': res,
			'change':obj[0],
			'callBack': function(res) {
				// console.log(res);
				if (res.code != '200') {
					obj.parents('.conTable').find('.err').show();
					obj.parents('.conTable').find('.err').html(res.msg);
				}
			}
		})
	}
</script>
